<?php

namespace App\Http\Controllers;

use App\Activity;
use Illuminate\Http\Request;
use Illuminate\Support\Carbon;

class ActivityController extends Controller
{
    public function activity_list(Request $request){
        return view('web.activity.list');
    }
    public  function get_more(Request $request){
       $activity= Activity::query();
       if($request->type==1){
           $activity=$activity->where('end_time','>',Carbon::now());
       }elseif($request->type==2){
           $activity=$activity->where('end_time','<',Carbon::now());
       }
        $activity= $activity->orderBy('id','desc')->paginate(10);
       return view('web.activity.get_more',compact('activity'));
    }
    public function detail(Request $request){
       $detail= Activity::findOrFail($request->id);
       return view('web.activity.detail',compact('detail'));
    }
}
